package org.example.rubbish.config;


import jakarta.websocket.HandshakeResponse;
import jakarta.websocket.server.HandshakeRequest;
import jakarta.websocket.server.ServerEndpointConfig;

public class CorsServerEndpointConfigurator extends ServerEndpointConfig.Configurator {
    @Override
    public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
        // 允许 localhost:8081
        response.getHeaders().put("Access-Control-Allow-Origin", java.util.Arrays.asList("http://localhost:8081","ws://localhost:8081"));
        super.modifyHandshake(sec, request, response);
    }
}